﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Travel.Web.banner
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtid.Text))
			{
				strErr+="主键格式错误！\\n";	
			}
			if(this.txtpage_name.Text.Trim().Length==0)
			{
				strErr+="页面名称不能为空！\\n";	
			}
			if(this.txtdisplay_name.Text.Trim().Length==0)
			{
				strErr+="显示名称不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txttype.Text))
			{
				strErr+="1 image 2 flash格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtcreated_on.Text))
			{
				strErr+="created_on格式错误！\\n";	
			}
			if(this.txtcreated_by.Text.Trim().Length==0)
			{
				strErr+="created_by不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtchanged_on.Text))
			{
				strErr+="changed_on格式错误！\\n";	
			}
			if(this.txtchanged_by.Text.Trim().Length==0)
			{
				strErr+="changed_by不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int id=int.Parse(this.txtid.Text);
			string page_name=this.txtpage_name.Text;
			string display_name=this.txtdisplay_name.Text;
			int type=int.Parse(this.txttype.Text);
			DateTime created_on=DateTime.Parse(this.txtcreated_on.Text);
			string created_by=this.txtcreated_by.Text;
			DateTime changed_on=DateTime.Parse(this.txtchanged_on.Text);
			string changed_by=this.txtchanged_by.Text;

			Travel.Model.banner model=new Travel.Model.banner();
			model.id=id;
			model.page_name=page_name;
			model.display_name=display_name;
			model.type=type;
			model.created_on=created_on;
			model.created_by=created_by;
			model.changed_on=changed_on;
			model.changed_by=changed_by;

			Travel.BLL.banner bll=new Travel.BLL.banner();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
